define(['jquery'], function () {

    function addBook(bookId, bookImageUrl, bookName, lastestChapter, lastUpdateTime) {
        book = "<div class='row' id=" + bookId + ">\n" +
            "        <div class='col-xs-4'>\n" +
            "            <img class='book_cover' src=" + bookImageUrl + " />\n" +
            "        </div>\n" +
            "        <div class='col-xs-8 text_continor'>\n" +
            "            <div class='book_title'>" + bookName + "</div>\n" +
            "            <div class='lastest_chapter'>" + lastestChapter + "</div>\n" +
            "            <div class='last_update_time'>" + lastUpdateTime + "</div>\n" +
            "        </div>\n" +
            "    </div>";

        $("#book_list").append(book);

        bookObj = $('#' + bookId);

        //按下
        bookObj.on('touchstart', function () {
            $(this).css("background-color", "#8881");
        });

        //抬起
        bookObj.on('touchend', function () {
            $(this).css('background-color', '');
        });

        //点击
        bookObj.on('click', function () {
            window.location.href = "read.html";
        })
    }

    function test() {
        for (var i = 0; i < 12; i++) {
            addBook(i, 'https://quapp.yphsy.com//BookFiles/BookImages/yinianyongheng.jpg', '一念永恒', '第1018章 绝望的魁皇城', '2017-09-09');
        }
    }

    //移动
    function init() {
        $('#book_list').on('touchmove', function () {
            $('#book_list>div').css('background-color', '');
        })
    }

    return {
        addBook: addBook,
        init: init
    }
});
